package com.gk.panda.apis.entity.eventtodo.vo;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @ClassName: EventToDoCountVo
 * @Description: 获取待办事件列表上的数据统计
 * @author: Sir.yang
 * @date: 2022/11/3 15:29
 * @version: 1.0
 **/
@Data
@ApiModel("获取待办事件列表上的数据统计")
public class EventToDoCountVo {

    @ApiModelProperty("上报事件总数")
    private Integer eventTotalNum;

    @ApiModelProperty("事件完成数")
    private Integer eventCompletedNum;

    @ApiModelProperty("事件完成率")
    private Float eventCompletionRate;


    public void setEventCompletionRate(Float eventCompletionRate) {
        if(null != eventTotalNum && null != eventCompletedNum){
            BigDecimal completedNum = new BigDecimal(eventCompletedNum);
            BigDecimal totalNum = new BigDecimal(eventTotalNum);
            this.eventCompletionRate = completedNum.divide(totalNum, 2, BigDecimal.ROUND_HALF_UP)
                    .multiply(new BigDecimal(100)).floatValue();
            return;
        }
        this.eventCompletionRate = eventCompletionRate;
    }
}
